package com.star.property;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyUtil {

	public static String getProvideUrl(String key, String fileName) {
		Properties properties = new Properties();
		InputStream is = null;

		try {
			is = PropertyUtil.class.getClassLoader().getResourceAsStream(
					fileName);
			properties.load(is);
			return properties.getProperty(key);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public static String getFilePath(String fileName) {
		return PropertyUtil.class.getResource("/").getPath() + fileName;
	}
	
	public static void main(String[] args) {
		System.out.println(getFilePath(""));
	}

	public static String getContentFromFile(String path) throws IOException {
		String content = "";
		File file = new File(path);
		BufferedReader reader = null;
		reader = new BufferedReader(new FileReader(file));
		String tempString = null;
		while ((tempString = reader.readLine()) != null) {
			content += tempString + "\n";
		}
		reader.close();
		return content;
	}

}
